let manage = new Vue({
    el:"#manage",
    data:{news:[]},
    methods:{
        addfood:function () {
            let data = new FormData(document.querySelector("form"))
            if (data != null) {
                axios.post("/news/insert", data).then(function (response) {
                    if (response.data == 1) {
                        alert("添加成功")
                        location.reload()
                    } else {
                        alert("添加失败")
                    }
                })
            }
        },
        del:function (id) {
            if (confirm("您确认删除吗?")){
                axios.get("/news/delete?id="+id).then(function () {
                    location.reload();//刷新页面
                })
            }
        }
    },
    created:function () {
        axios.get("/news/select").then(function (response) {
            manage.news=response.data;
        })
    }

})